﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using SBPweb.Modules.Smartparts;
using SBPweb.Modules.Modularity;

namespace SBPweb.MediaCenter.Modules.Player.WPF.Controls
{
    /// <summary>
    /// Interaction logic for PlayerControl.xaml
    /// </summary>
    public partial class PlayerControl : UserControl, ISmartpart
    {

        #region Private fields

        private bool isModal;
        private Aligning align;
        private IModule parentModule;

        #endregion

        #region Constructor logic

        public PlayerControl(IModule parentModule)
        {
            this.parentModule = parentModule;
            InitializeComponent();
        }

        #endregion

        #region Property accessors

        public Aligning Align
        {
            get
            {
                return align;
            }
            set
            {
                align = value;
            }
        }

        public IModule ParentModule
        {
            get
            {
                return parentModule;
            }
        }

        public new bool IsVisible
        {
            get
            {
                return base.IsVisible;
            }
            set
            {
                if (value)
                {
                    base.Visibility = Visibility.Visible;
                }
                else
                {
                    base.Visibility = Visibility.Hidden;
                }
            }
        }

        public bool IsModal
        {
            get
            {
                return isModal;
            }
        }

        #endregion

        #region Events

        public event EventHandler VisibleChanged;

        public event EventHandler EnabledChanged;

        #endregion

        #region Event handlers

        public void Open(Uri uri)
        {
            mediaElement1.Source = uri;
            mediaElement1.Play();
        }

        public void Open(Stream stream)
        {
            throw new NotImplementedException();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (mediaElement1.IsLoaded)
            {
                mediaElement1.Play();
            }
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (mediaElement1.IsLoaded)
            {
                mediaElement1.Pause();
            }
        }

        #endregion

    }
}
